package server.content.dungeons;

import java.util.LinkedList;
import java.util.List;

import server.game.players.Client;

/**
 * 
 * @author Miracle
 * 
 */
public abstract class Dungeon {

	private final List<DungeonObject> objects = new LinkedList<DungeonObject>();
	public final Client c;

	public Dungeon(final Client c) {
		this.c = c;
		initObjects();
	}

	/**
	 * Handles Dungeon Object Clicking.
	 * 
	 * @param objectId
	 *            object id to handle.
	 * @param x
	 *            coordinate of object.
	 * @param y
	 *            coordinate of object.
	 */
	public void handleObjects(final int objectId, final int x, final int y) {
		for (final DungeonObject object : objects) {
			if (object == null)
				continue;
			if (object.getObjectId() == objectId) {
				if (object.getX() < 0) {
					if (object.getY() == y)
						object.handleObject();
				} else if (object.getY() < 0) {
					if (object.getX() == x)
						object.handleObject();
				}
			}
		}
	}

	public abstract void initObjects();

	public void addDungeonObject(final DungeonObject object) {
		if (objects.contains(object))
			return;
		objects.add(object);
	}

}
